package com.zhanghp.common;

import java.util.Stack;

import static java.lang.Math.*;
/**
 * @author zhanghp
 * @since 2024/6/20 16:32
 */
public class StackUtil {

    public static Stack<Integer> random(int size, int maxVal){
        Stack<Integer> stack = new Stack<>();
        size = (int)(Math.random() * size) + 1;
        for (int i = 0; i < size; i++) {
            stack.add((int)(Math.random() * maxVal) + 1);
        }
        return stack;
    }

    public static boolean checkSort(Stack<Integer> stack){
        int step = Integer.MIN_VALUE;
        while (!stack.isEmpty()) {
            if (step > stack.peek()) {
                return false;
            }
            step = stack.pop();
        }
        return true;
    }
}
